package org.homly.admin.tag.scheme;

import java.util.HashMap;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.homly.sql.SQLTool;


	
@SuppressWarnings("serial")
public class ViewSchemeTag extends TagSupport {
	private String name = "main";
	private String name1 = "details";
	private String id = null;
	
	
	@Override
	public int doStartTag() throws JspException {
		try {
			if(id == null || !id.matches("\\d+")) return super.doStartTag();
			long schemeId = Long.parseLong(id);
			String sql = "select * from scheme where scheme_status=1 and scheme_id=" + schemeId;
			List<HashMap<String, String>> list = SQLTool.query(sql);
			if(list != null && list.size() > 0) {
				pageContext.setAttribute(name, list.get(0));
			}
			sql = "select * from scheme_detail where scheme_id=" + schemeId;
			List<HashMap<String, String>> detailList = SQLTool.query(sql);
			if(detailList != null && detailList.size() > 0) {
				pageContext.setAttribute(name1, detailList);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}


	public void setName(String name) {
		this.name = name;
	}


	public void setId(String id) {
		this.id = id;
	}


	public void setName1(String name1) {
		this.name1 = name1;
	}

}


